package com.mz.mattress.api.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 执行状态
 * 0未开始 1已取消 2执行中 3报错中断 4成功
 */
public enum TaskStatusEnum {

    INIT(0, "未开始"),
    CANCEL(1, "已取消"),
    RUNNING(2, "执行中"),
    FAILED(3, "报错中断"),
    SUCCESS(4, "成功"),
    ;

    private Integer value;

    private String desc;

    TaskStatusEnum(final Integer value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    private static Map<Integer, TaskStatusEnum> map = new HashMap<>();

    static {
        for (TaskStatusEnum stepEnum : TaskStatusEnum.values()) {
            map.put(stepEnum.value, stepEnum);
        }
    }

    public static TaskStatusEnum valueOf(int value) {
        return map.get(value);
    }

    public Integer getValue() {
        return this.value;
    }

    public String getDesc() {
        return this.desc;
    }
}
